/**
 * Created by jiangqifan on 2017/6/20.
 */
(function() {
    ADF.actionModel.CopyModel = function() {
        ADF.actionModel.CopyModel.superclass.constructor.call(this);
        this.config = {text:"复制",icon:"icon-fuzhi"};
        this.id = "copy";
    };

    COM.util.defineClass(ADF.actionModel.CopyModel, AGEF.ActionModel, {
        execute: function(graphicalViewer){
            var selections = graphicalViewer.getSelection();
            var models = [];
            for(var i = 0; i < selections.length; i++){
              models[i] = selections[i].model.serialize();
            }
            this.performCopy(JSON.stringify(models));
        },
        performCopy: function(models){
          ADF.actionModel.CopyModel.clipboard="adfmodels:"+models;
        },
        getEnabledState : function(graphicalViewer){
            var selections = graphicalViewer.getSelection();
            if(!selections){
              return false;
            }
            //Diagram不允许调整顺序
            if(selections.length == 1 && COM.util.isInstanceOf(selections[0], ADF.editpart.DiagramEditPart)){
              return false;
            }
            return selections.length>0;
        }
    });
})();
